﻿@using WaterRevenueMS.WebUI.Extension.MvcHelper
@using WaterRevenueMS.Domain.ViewModels.Authen.Module
@model ModuleModel

@using (Html.BeginForm("Edit", "Module", FormMethod.Post, new { @class = "form-horizontal", @id = "modal-content" }))
{
@Html.HiddenFor(t => t.Id)

<div class="control-group">
    <label class="control-label-form">
        <label class="red">*</label>模块名称 : :           
    </label>
    <div class="controls">
        <label class="label-text">
            @Html.TextBoxFor(t => t.Name, new { @class = "form-control" })                
        </label>
    </div>
</div>

<div class="control-group">
    <label class="control-label-form">
        <label class="red">*</label>模块编号 :         
    </label>
    <div class="controls">
        @Html.TextBoxFor(t => t.Code, new { @class = "form-control" })        
    </div>
</div>

<div class="control-group">
    <label class="control-label-form">
        上级模块 :         
    </label>
    <div class="controls">
        @Html.DropDownListFor(t => t.ParentId, Model.ParentModuleItems, new { @class = "form-control" })             
    </div>
</div>

<div class="control-group">
    <label class="control-label-form">
        菜单图标 :
    </label>
    <div class="controls">
        @Html.TextBoxFor(t => t.Icon, new { @class = "form-control" })
    </div>
</div>

<div class="control-group">
    <label class="control-label-form">
        链接地址 :         
    </label>
    <div class="controls">
        @Html.TextBoxFor(t => t.LinkUrl, new { @class = "LinkUrl form-control" })     
        @Html.ValidationMessageFor(m => m.LinkUrl)        
    </div>
</div>

<div class="control-group">
    <label class="control-label-form">
        <label class="red">*</label>排序 :        
    </label>
    <div class="controls">
        @Html.TextBoxFor(t => t.OrderSort, new { @class = "form-control" })
        @Html.ValidationMessageFor(m => m.OrderSort)           
    </div>
</div>

<div class="control-group">
    <label class="control-label-form">
        是否菜单 :          
    </label>
    <div class="controls">
        @Html.CheckBoxFor(t => t.IsMenu)          
    </div>
</div>

<div class="control-group">
    <label class="control-label-form">
        是否激活 :          
    </label>
    <div class="controls">
        @Html.CheckBoxFor(t => t.Enabled)          
    </div>
</div>
}
@Html.ScriptBlock(
    @<script type="text/javascript">
        $(function () {
            $(".LinkUrl").autocomplete(
                {
                    source: function (request, response) {
                        $.ajax({
                            type: "GET",
                            url: "@Url.Action("GetModuleLinkUrl")",
                            data: { "term": request.term },
                            dataType: 'json',
                            success: function (data) {
                                response($.map(data, function (item) {
                                    return {
                                        label: item.LinkUrl,
                                        value: item.LinkUrl
                                    }
                                }));
                            }
                        });
                    },
                    minChars: 0,
                    max: 10,
                    autoFill: true,
                    mustMatch: true,
                    matchContains: true,
                    change: function (event, ui) {
                        var result = false;
                        var source = $(this).val();
                        $(".ui-autocomplete li").each(function () {
                            if (source == $(this).text()) {
                                result = true;
                                return true;
                            }
                        });
                        if (!result) {
                            $(this).val('');
                        }
                    }
                });
        })
    </script>
    )